Redim
Basic syntax x(n)
Use Redim x[n] (with the square brackets) only in Crystal syntax, and Redim x(n) (with the round brackets) only in Basic syntax.
Usage
Redim x(n)
Re-dimension the array x to size n, where x is an array and n is a positive whole number specifying the new size of x.
Examples
The following example is applicable to Basic syntax:
Dim x() As String
'Initialize first three array elements
x = Array ("a", "bb", "ccc")
'Re-size x to 4; old values are ignored
'x is now equal to Array ("", "", "", "")
Redim x(4)
'x is now equal to Array ("", "", "", "dddd")
x(4) = "dddd"
formula = x(4)
Comments
When an array is re-dimensioned with Redim, elements in the array are filled with default values for that type. See Default values for the simple types (Basic syntax).
Related topics
Array data types (Basic syntax)
Using array variables (Basic syntax)
Crystal syntax x[n]
- Use Redim x[n] (with the square brackets) only in Crystal syntax, and Redim x(n) (with the round brackets) only in Basic syntax.
- Unlike Redim x(n) in Basic syntax, a Redim statement in Crystal syntax cannot have multiple arrays.
Usage
Redim x[n]
Re-dimension the array x to size n, where x is an array and n is a positive whole number specifying the new size of n.
Examples
The following example is applicable to Crystal syntax:
Local StringVar array x:= ["a", "bb", "ccc"];
// resize the array to size 4; old values are ignored
// and filled with default values of empty strings
Redim x [4];
x [4] := "dddd"; // only x[4] is initialized
Comments
When an array is re-dimensioned with Redim, elements in the array are filled with default values for that type. See Default values for the simple types (Crystal syntax).
Related topics
Array data types (Crystal syntax)
Using array variables (Crystal syntax)